/**
 * Created by dqw on 2015/12/30.
 */

//列表开始
var dtGridColumns = [
    {
        id: 'id',
        title: 'ID',
        type: 'number',
        columnClass: 'text-center width-20',
        fastSort: true,
        fastQuery: true,
        fastQueryType: 'eq'
    },
    {
        id: 'userId',
        title: '客户ID',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left ',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq'
    },
    {
        id: 'u.mobilePhone',
        title: '电话',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left ',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq'
    },
    {
        id: 'direction',
        title: '流向',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left ',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq',
        codeTable:{
            1:$lang.direction.payment,
            2:$lang.direction.receive
        }
    },
    {
        id: 'type',
        title: '资金变动类型',
        type: 'string',
        headerClass: 'text-left',
        columnClass: 'text-left',
        fastSort: false,
        fastQuery: false,
        fastQueryType: 'lk',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            if (record.type == 1) {
                return "充值";
            }
            if (record.type == 2) {
                return "提现";
            }
            if (record.type == 3) {
                return "收入";
            }
            if (record.type == 4) {
                return "支出";
            }
            if (record.type == 5) {
                return "提现手续费";
            }
            if (record.type == 6) {
                return "结算手续费";
            }
            if (record.type == 7) {
                return "买入";
            }
            if (record.type == 8) {
                return "提现冻结";
            }
            if (record.type == 9) {
                return "提现解冻";
            }
            if (record.type == 10) {
                return "冻结履约保证金";
            }
            if (record.type == 11) {
                return "扣除综合管理费";
            }
            if (record.type == 12) {
                return "递延费";
            }
            if (record.type == 13) {
                return "冻结止盈保证金";
            }
            if (record.type == 14) {
                return "解冻";
            }
            if (record.type == 15) {
                return "收益";
            }
            if (record.type == 16) {
                return "亏损";
            }
            if (record.type == 17) {
                return "扣除未支付的递延费";
            }
            if (record.type == 18) {
                return "销售佣金";
            }
            if (record.type == 19) {
                return "收取综合管理费";
            }
            if (record.type == 20) {
                return "补亏";
            }
            if (record.type == 21) {
                return "手续费佣金";
            }
            if (record.type == 22) {
                return "盈利佣金";
            }
            if (record.type == 23) {
                return "综合费用成本";
            }
        }
    },
    {
        id: 'amount',
        title: '资金变动(元)',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-right ',
        fastSort: true,
        format:'#,##0.00'
    },
    {
        id: 'total',
        title: '剩余金额(元)',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-right ',
        fastSort: true,
        format:'#,##0.00'
    },
    {
        id: 'createTime',
        title: '时间',
        type: 'date',
        format:'yyyy-MM-dd',
        headerClass: 'text-left',
        columnClass: 'text-left ',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'range'
    }
];


var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + 'moneyDetail/list.json',
    exportFileName: '资金记录列表',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    pageSize: 10,
    pageSizeLimit: [10, 20, 50],
    ncColumnsType: {int:["id","userId","investId","tradeCredit","status","direction","orderId"],Timestamp:["buyTime","acceptTime","buyDealTime","eveningUpTime","sellTime","sellDealTime","createTime"],BigDecimal:["buyPrice","sellPrice","profitCount"]}
};

var grid = $.fn.DtGrid.init(dtGridOption);
//默认查询条件
grid.fastQueryParameters = new Object();
grid.fastQueryParameters['eq_order_id'] = $('#orderId').val();

//排序
grid.sortParameter.columnId = 'id';
grid.sortParameter.sortType = 1;

//列表结束

//操作处理开始
var OperateHandle = function () {

    function _bindEvent() {

        //新增对话框初始化
        $("#addModal").on("show.bs.modal", function (event) {

        });

        //编辑对话框初始化
        $("#editModal").on("show.bs.modal", function (event) {

        });

        //模糊搜索
        $('#customSearch').click(function () {

        });
    }

    //外部可调用
    return {
        bindEvent: _bindEvent,
        delAdmin: _delAdmin
    }
}();
//操作处理结束

$(function () {
    //加载列表
    grid.load();
    //页面绑定事件
    OperateHandle.bindEvent();
});